<template>
  <div>
    <div class="select_container">
      <div
        class="select_item_box"
        v-for="(item, index) in selectedData"
        :key="index"
      >
        <img :src="item.pic" />
        <div class="item_position">
          <div class="item_position_box">
            <div class="item_title">{{ item.title }}</div>
            <div class="item_desc">{{ item.descript }}</div>
            <div class="item-button">
              <button @click="onClick(item.id)">查看详情</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    selectedData: {
      type: Array,
      required: true,
    },
  },
  methods: {
      onClick(id){//点击跳转详情页
        this.$router.pushRouteByQuery("/selectedDetails",id)
      }
  },
};
</script>
<style lang="scss" scoped>
.select_container {
  width: 100%;
  display: inline-flex;
  flex-wrap: wrap;
  .select_item_box {
    margin-top: 0.2rem;
    width: 100%;
    height: 10rem;
    position: relative;
    img {
      width: 100%;
      height: 100%;
    }
    .item_position {
      width: 100%;
      height: 5rem;
        // background: red;
      position: absolute;
      top: 50%;
      margin-top: -2.5rem;
      .item_position_box {
          width: 100%;
          height: 100%;
          display: inline-flex;
          align-items: center;
          flex-wrap: wrap;
        .item_title {
          width: 80%;
        //   background: green;
          margin-left: 10%;
          text-align: center;
          font-size: 0.9rem;
          color: white;
          white-space: nowrap; //强制不换行
          overflow: hidden; //超出部分隐藏
          text-overflow: ellipsis; //显示‘...’
        }
        .item_desc {
          width: 90%;
          font-size: 0.7rem;
          margin-left: 5%;
          text-align: center;
          color: white;
          white-space: nowrap; //强制不换行
          overflow: hidden; //超出部分隐藏
          text-overflow: ellipsis; //显示‘...’
        }
        .item-button {
          width: 100%;
          display: inline-flex;
          justify-content: center;
          align-items: center;
          button {
            font-size: 0.7rem;
            background: none;
            outline: none;
            padding: 0.2rem 0.5rem;
            border: 1px solid white;
            border-radius: 0.6rem;
            color: white;
          }
        }
      }
    }
  }
}
</style>